<?php
/**
 * Created by PhpStorm.
 * User: songs
 * Date: 2020/5/16
 * Time: 16:03
 */

namespace App\admin\FormView;


use App\Models\Admin\OrderBaleModel;
use App\Models\Admin\OrderTempModel;
use App\Models\Admin\UserModel;
use App\Models\JobsCompanysModel;
use App\Models\NewsModel;

class UserInfoFormView extends BaseViewForm
{
    public function get_model()
    {
        return new UserModel();
    }

  /**
     * 表单提交按钮显示的文本,如果为空,则不现实按钮
     */
    public $submit =false;
    /**
     * 是否为只读模式
    */
    protected $readOnly=true;

     /**
     * 方便继承,多一层过滤
     */
    public function ModelTohtml($key, $model)
    {
        if($key=='orderDocking'){
            $count=OrderTempModel::where([
                'fid'=>$model->id
            ])->count();
            return '<a title="点击查看详情" target="_blank" class="count" 
            href="/mcadmin/basic/order/temp?fid='.$model->id.'">共查询到:<span
            style="    color: #ff0000;
    font-size: 22px;
    font-weight: bold;"
             >'.$count.'</span>条记录</a>';
        }

        if($key=='huodanlist'){
            $count=OrderBaleModel::where([
                'uid'=>$model->id
            ])->count();
            return '<a title="点击查看详情" target="_blank" class="count" 
            href="/mcadmin/huodan/list?uid='.$model->id.'">共查询到:<span
            style="    color: #ff0000;
    font-size: 22px;
    font-weight: bold;"
             >'.$count.'</span>条记录</a>';
        }


        if($key=='zhaopin'){
            $count=JobsCompanysModel::where([
                'cid'=>$model->id,
                'del'=>0
            ])->count();
            return '<a title="点击查看详情" target="_blank" class="count" 
            href="/mcadmin/basic/jobList?cid='.$model->id.'">共查询到:<span
            style="    color: #ff0000;
    font-size: 22px;
    font-weight: bold;"
             >'.$count.'</span>条记录</a>';
        }


        if($key=='zixun'){
            $count=NewsModel::where([
                'cid'=>$model->id
            ])->count();
            return '<a title="点击查看详情" target="_blank" class="count" 
            href="/mcadmin/basic/newslist?cid='.$model->id.'">共查询到:<span
            style="    color: #ff0000;
    font-size: 22px;
    font-weight: bold;"
             >'.$count.'</span>条记录</a>';
        }






        return $model->$key;
    }

    /**
     * 需要继承,然后定义每行需要显示的数据格式
     */
    public function Labels()
    {
        return [
            [
                'title' => 'ID',
                'field' => 'id',
                'type' => self::labeltextshow
            ],
            [
                'title' => '手机号码',
                'field' => 'phone',
                'type' => self::labeltextshow
            ],
            [
                'title' => '昵称',
                'field' => 'name',
                'type' => self::labeltextshow
            ],
            [
                'title' => '头像',
                'field' => 'head',
                'type' => self::labelPic
            ],
            [
                'title' => '余额',
                'field' => 'money',
                'type' => self::labeltextshow
            ],
            [
                'title' => '创建时间',
                'field' => 'created_at',
                'type' => self::labeltextshow
            ],
            [
                'title' => '启用公司',
                'field' => 'is_company',
                'type' => self::labelDownList,
                'list' => [
                    0 => '关闭',
                    1 => '启用',
                ]
            ],
            [
                'title' => '启用工厂',
                'field' => 'is_factory',
                'type' => self::labelDownList,
                'list' => [
                    0 => '关闭',
                    1 => '启用',
                ]
            ],
            [
                'title' => '启用应聘',
                'field' => 'is_yingpin',
                'type' => self::labelDownList,
                'list' => [
                    0 => '关闭',
                    1 => '启用',
                ]
            ],
            [
                'title' => '头像',
                'field' => 'head',
                'type' => self::labelPic
            ],
            [
                'title' => '备注',
                'field' => 'notes',
                'type' => self::labeltextshow
            ],
            [
                'title' => '对接订单',
                'field' => 'orderDocking',
                'type' => self::labeltextshow
            ],
            [
                'title' => '发布的货单',
                'field' => 'huodanlist',
                'type' => self::labeltextshow
            ],
            [
                'title' => '发布的招聘',
                'field' => 'zhaopin',
                'type' => self::labeltextshow
            ],
            [
                'title' => '发布的咨询',
                'field' => 'zixun',
                'type' => self::labeltextshow
            ],

            [
                'title' => '性别',
                'field' => 'sex',
                'type' => self::labelDownList,
                'must' => true,
                'save'=>true,
                'attr' => ['test' => '123'],
                'list' => [
                    ///1男，2女，
                    0 => '未知',
                    1 => '男',
                    2 => '女'
                ]
            ],

        ];
    }
}